package com.el.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.el.biz.TitleBiz;
import com.el.biz.impl.TitleBizImpl;
import com.el.bojo.Title;

public class TitleServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String name = request.getParameter("name");
		String password = request.getParameter("password");
		HttpSession session=request.getSession();
		TitleBiz titleBiz=new TitleBizImpl();
		List<Title> list =titleBiz.getAllTitle();
		
		if (name.equals("admin")) {
			session.setAttribute("login", "admin");
			session.setAttribute("titlelist", list);
			response.sendRedirect("work5admin.jsp");
		}else{
			session.setAttribute("login", "user");
			session.setAttribute("titlelist", list);
			response.sendRedirect("work5admin.jsp");
		}

	}

}
